// 用户类型别名
export type User = UserInfo

// 用户信息类型
export interface UserInfo {
  userId: number
  username: string  // 修改为与后端一致
  nickName: string
  realName?: string
  email: string
  phoneNumber: string
  gender: string
  birthday?: string
  avatar: string
  deptId: number
  deptName: string
  postIds: number[]
  postNames: string[]
  roleIds: number[]
  roleNames: string[]
  permissions: string[]
  roles: string[]
  status: string
  userType?: string
  loginTime?: string
  loginIp?: string
  createTime: string
  updateTime?: string
  createBy?: string
  updateBy?: string
  remark?: string
  version?: number
}

// 登录参数类型
export interface LoginParams {
  username: string  // 修改为与后端一致
  password: string
  captcha: string
  captchaKey: string
  rememberMe?: boolean
}

// Token信息类型
export interface TokenInfo {
  accessToken: string
  refreshToken: string
  expiresIn: number
  tokenType: string
}

// 登录响应类型（经过request拦截器处理后的实际数据结构）
export interface LoginResponse {
  accessToken: string
  refreshToken: string
  tokenType: string
  expiresIn: number
  userInfo: {
    userId: number
    username: string
    nickname: string
    avatar: string
    email: string
    mobile: string
    deptId: number
    deptName: string
    roles: string[]
    permissions: string[]
  }
}

// 用户信息响应类型（经过request拦截器处理后的实际数据结构）
export interface UserInfoResponse {
  userInfo: UserInfo
  permissions: string[]
  roles: string[]
}

// 用户查询参数类型
export interface UserQuery {
  pageNum: number
  pageSize: number
  userName?: string
  nickName?: string
  status?: string
  deptId?: number
  beginTime?: string
  endTime?: string
}

// 用户表单类型
export interface UserForm {
  userId?: number
  userName: string
  nickName: string
  realName?: string
  email: string
  phoneNumber: string
  gender: string
  birthday?: string
  avatar?: string
  status: string
  userType?: string
  deptId: number
  postIds: number[]
  roleIds: number[]
  remark?: string
  version?: number
}

// 用户创建表单类型
export interface UserCreateForm extends Omit<UserForm, 'userId' | 'version'> {
  password: string
  confirmPassword: string
}

// 用户更新表单类型
export interface UserUpdateForm extends UserForm {
  userId: number
}

// 密码修改类型
export interface PasswordForm {
  oldPassword: string
  newPassword: string
  confirmPassword: string
}

// 个人资料类型
export interface ProfileForm {
  nickName: string
  email: string
  phoneNumber: string
  sex: string
  avatar: string
  userName?: string
  status?: string
}

// 重置密码类型
export interface ResetPasswordForm {
  userId: number
  newPassword: string
  confirmPassword: string
  reason?: string
}

// 修改密码类型
export interface ChangePasswordForm {
  oldPassword: string
  newPassword: string
  confirmPassword: string
}

// 导入结果类型
export interface ImportResult {
  successCount: number
  failureCount: number
  failureList: Array<{
    row: number
    reason: string
  }>
}

// 用户详情类型
export interface UserDetail extends UserInfo {
  loginIp: string
  loginDate: string
  updateTime: string
  updateBy: string
  version: number
  tenantId: number
}
